package org.ekstrabilet.stadium.logic;

import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.util.LinkedList;

import org.ekstrabilet.game.beans.Game;
import org.ekstrabilet.game.beans.SectorPrice;
import org.ekstrabilet.game.logic.GameLogic;
import org.ekstrabilet.logic.exceptions.StadiumException;
import org.ekstrabilet.stadium.beans.Row;
import org.ekstrabilet.stadium.beans.Seat;
import org.ekstrabilet.stadium.beans.Sector;
import org.ekstrabilet.stadium.beans.Stadium;
import org.ekstrabilet.stadium.beans.Tribune;
import org.ekstrabilet.ticket.beans.Ticket;
import org.ekstrabilet.ticket.logic.TicketLogic;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Stadium stadium= new Stadium();
		stadium.setCapacity(800);
		stadium.setCity("testCity");
		stadium.setName("testStadium");
		Tribune[] tribune= new Tribune[4];
		tribune[0]= createTribune(1);
		tribune[1]= createTribune(2);
		tribune[2]= createTribune(3);
		tribune[3]= createTribune(4);
		stadium.setTribunes(tribune);
		StadiumLogic logic= StadiumLogic.getInstance();
		Stadium stad= null;
		try {
			logic.addStadium(stadium);
		} catch (StadiumException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//stad.getTribune(1).getSector(1).getRows();
		GameLogic log= GameLogic.getInstance();
		LinkedList<Game> games= new LinkedList<Game>();
		
		Game game= new Game("sadf", "lsdjfl", "xxxxx", "Krakow", new Date(6987787) , new Time(23434));
		LinkedList<SectorPrice> prices= new LinkedList<SectorPrice>();
		SectorPrice price= new SectorPrice(10, 12122);
		prices.add(price);
		price= new SectorPrice(11, 12122);
		prices.add(price);
		price= new SectorPrice(12, 12122);
		prices.add(price);
		price= new SectorPrice(13, 12122);
		prices.add(price);
		price= new SectorPrice(14, 12122);
		prices.add(price);
		game.setSectorPrices(prices);
		games.add(game);
		game= new Game("sadf", "lsdjfl", "xxxxx", "Krakow", new Date(6987787) , new Time(23434));
		prices= new LinkedList<SectorPrice>();
		price= new SectorPrice(10, 12122);
		prices.add(price);
		price= new SectorPrice(11, 12122);
		prices.add(price);
		price= new SectorPrice(12, 12122);
		prices.add(price);
		price= new SectorPrice(13, 12122);
		prices.add(price);
		price= new SectorPrice(14, 12122);
		prices.add(price);
		game.setSectorPrices(prices);
		games.add(game);
		
		games= new LinkedList<Game>();
		game= new Game(5, "sadf", "lsdjfl", "xxxxx", "Krakow", new Date(6987787) , new Time(23434));
		games.add(game);
		game= new Game(6, "sadf", "lsdjfl", "xxxxx", "Krakow", new Date(6987787) , new Time(23434));
		games.add(game);
	/*	try {
			
				log.removeGames(games);
		
		} 
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		Ticket ticket= new Ticket();
		ticket.setGameId(1);
		ticket.setRow(2);
		ticket.setSeat(3);
		ticket.setSectorId(1);
		ticket.setStadium(stadium);
		ticket.setTribune(2);
		
		TicketLogic ticketLogic= TicketLogic.getInstance();
		ticketLogic.addTicket(ticket);
		//logic.findSectorIdBy_SN_SC_TN_ST("xxxxx", "Krakow", 2, "A");
		 
		 */
	}
	
	private static Tribune createTribune(int num){
		Tribune tribune= new Tribune();
		Sector sector= new Sector();
		for(int i=0; i<7; i++){
			Row row= new Row();
			for(int j=0; j<10; j++){
				Seat seat= new Seat();
				row.addSeat(seat);
			}
			sector.addRow(row);
		}
		sector.setSign('A');
		tribune.addSector(sector);
		
		sector= new Sector();
		for(int i=0; i<7; i++){
			Row row= new Row();
			for(int j=0; j<10; j++){
				Seat seat= new Seat();
				row.addSeat(seat);
			}
			sector.addRow(row);
		}
		sector.setSign('B');
		tribune.addSector(sector);
		tribune.setNumber(num);
		tribune.setCapacity(140);
		return tribune;

	}

}
